package com.htfyun.ft.fragment.factory;

import android.os.Bundle;
import android.os.Message;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.htfyun.ft.R;
import com.htfyun.ft.utils.DebugLog;
import com.htfyun.ft.view.CameraTextureView;

import androidx.annotation.Nullable;

public class FragmentCamera extends FactoryBaseFragment {

    private CameraTextureView cameraTextureView;
    @Override
    protected int getLayoutRes() {
        return R.layout.fragment_factory_camera;
    }

    @Override
    protected void onInitView(@Nullable Bundle savedInstanceState) {
        super.onInitView(savedInstanceState);

        cameraTextureView = findViewById(R.id.cameraTextureView);

        cameraTextureView.setCameraTextureCallback(new CameraTextureView.CameraTextureCallback() {
            @Override
            public void onCameraOpenOK() {

            }

            @Override
            public void onCameraDisconnected() {

            }

            @Override
            public void onCameraError() {

                getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(getContext(), R.string.camera_not_found, Toast.LENGTH_LONG).show();
                        finishMeWithPassed(false);
                    }
                });

            }

            @Override
            public void onCameraPreview() {

            }
        });
    }

}
